﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using System.Drawing;


using CImPortImage;

using System.Collections.ObjectModel;

using Microsoft.Win32;


namespace CBackImageWpf
{
    /// <summary>
    /// winBackImage.xaml 的交互逻辑
    /// </summary>
    public partial class winBackImage : Window
    {


        public winBackImage()
        {
            InitializeComponent();

            this._images = new ObservableCollection<InsertImage>();
        }



        /// <summary>
        /// 初始化对应的信息
        /// </summary>
        /// <param name="images"></param>
        public winBackImage(List<InsertImage> images)
        {
            InitializeComponent();
            this._images = new ObservableCollection<InsertImage>();
            if (images != null)
            {
                foreach (InsertImage img in images)
                {
                    this._images.Add(img);
                }
            }
        }


        ObservableCollection<InsertImage> _images;
        public ObservableCollection<InsertImage> Images
        {
            get { return _images; }
            set { _images = value; }
        }
        
        ImportImageControl _control;
        
    public System.Drawing.PointF mLeftBelow =new PointF ();// '左下坐标
    public System.Drawing.PointF mRightUpper=new PointF ();//   '右上坐标

    GEEditor.GoogleParam _google = new GEEditor.GoogleParam();

    public GEEditor.GoogleParam Google
    {
        get { return _google; }
        set { _google = value; }
    }
    /// <summary>
    /// 得到网格的左下角与右上角坐标
    /// </summary>
    /// <param name="minX"></param>
    /// <param name="xStep"></param>
    /// <param name="xCount"></param>
    /// <param name="minY"></param>
    /// <param name="yStep"></param>
    /// <param name="yCount"></param>
    public void GetGrid(double minX, double xStep, int xCount, double minY, double yStep, int yCount)
    {
        mLeftBelow.X = Convert.ToSingle(minX);
        mLeftBelow.Y = Convert.ToSingle(minY);



        mRightUpper.X = Convert.ToSingle(minX + (xCount - 1) * xStep);
        mRightUpper.Y = Convert.ToSingle(minY + (yCount - 1) * yStep);
    }
 

        private void btnImport_Click(object sender, RoutedEventArgs e)
        {           
            OpenFileDialog sfd = new OpenFileDialog();
            sfd.Filter = "Image Files(*.JPG;*.GIF;*.BMP)|*.JPG;*.GIF;*.BMP;*.JPEG";
            if (sfd.ShowDialog() == true)
            {
                InsertImage image = new InsertImage();
                image.FileName = sfd.FileName;
                string fname = sfd.FileName;
                if (image.LoadBitmap(sfd.FileName) == false)
                {
                    return;
                }

                image.FileNameNoExen = InsertImage.GetFileName(ref fname);

                //加入对应的图片

                for (int i = 0; i < this.lstFile.Items.Count; i++)
                {
                    if (this.lstFile.Items[i].ToString() == image.FileNameNoExen)
                    {
                        MessageBox.Show("不能导入相同名称的位图,请核查！", "提示", MessageBoxButton.OK);
                        return;
                    }
                }



                this._images.Add(image);     
                this.lstFile.Items.Add(image.FileNameNoExen);
                this._images[this._images.Count - 1].Method = 1;
                this.lstFile.SelectedIndex = this._images.Count - 1;
             
            }


        }

        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            int index = this.lstFile.SelectedIndex;
            if (index != -1)
            {
                this._images.RemoveAt(index);
                this.lstFile.Items.RemoveAt(index);
                if (index > this.lstFile.Items.Count - 1)
                {
                    index = index - 1;
                }
                this.lstFile.SelectedIndex = index;
                ShowImage();
            }
        }

     



        private void btnDistance_Click(object sender, RoutedEventArgs e)
        {
            //     Me.ImportImageControl1.SetMouseType(1) '箭头形
            //Me.ImportImageControl1.MouseMoveType = 1 '移动
            //Me.ImportImageControl1.SetMouseType(1)
            //'定位第2个点
            //Me.ImportImageControl1.SetPoint = CImPortImage.PointType.DistancePoint_1
            //Me.Refresh()

         

            this._control.SetMouseType(1);
            this._control.MouseMoveType = 1;
            this._control.SetMouseType(1);

            this._control.SetPoint = PointType.DistancePoint_1;
            this._control.Refresh();
            int index = this.lstFile.SelectedIndex;
            if (index != -1)
            {
                this._images[index] = this._control.InsertImage.Clone();
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _control = this.frmHost.Child as ImportImageControl;

            if (this._images.Count > 0)
            {
                this.lstFile.SelectedIndex = this._images.Count - 1;
                ShowImage();
            }
        }

        private void btnSomePoint_Click(object sender, RoutedEventArgs e)
        {
            //      Me.ImportImageControl1.SetMouseType(1) '箭头形
            //Me.ImportImageControl1.MouseMoveType = 1 '移动
            //Me.ImportImageControl1.SetMouseType(1)
            //'定位第2个点
            //Me.ImportImageControl1.SetPoint = CImPortImage.PointType.DistancePoint_Certain
            //Me.Refresh()

            this._control.SetMouseType(1);
            this._control.MouseMoveType = 1;

            this._control.SetMouseType(1);

            this._control.SetPoint = PointType.DistancePoint_Certain;

            this._control.Refresh();
            int index = this.lstFile.SelectedIndex;
            if (index != -1)
            {
                this._images[index] = this._control.InsertImage.Clone();
            }
        
        }


        private void btnP1_Click(object sender, RoutedEventArgs e)
        {

            //       Me.ImportImageControl1.SetMouseType(1) '箭头形
            //Me.ImportImageControl1.MouseMoveType = 1 '移动
            //Me.ImportImageControl1.SetMouseType(1)
            //'定位第一个点
            //Me.ImportImageControl1.SetPoint = CImPortImage.PointType.TwoPoint_1
            //Me.Refresh()

            this._control.SetMouseType(1);
            this._control.MouseMoveType = 1;

            this._control.SetMouseType(1);

            this._control.SetPoint = PointType.TwoPoint_1;

            this._control.Refresh();
            int index = this.lstFile.SelectedIndex;
            if (index != -1)
            {
                this._images[index] = this._control.InsertImage.Clone();
            }
        }

        private void btnP2_Click(object sender, RoutedEventArgs e)
        {


            this._control.SetMouseType(1);
            this._control.MouseMoveType = 1;

            this._control.SetMouseType(1);

            this._control.SetPoint = PointType.TwoPoint_2;

            this._control.Refresh();
            int index = this.lstFile.SelectedIndex;
            if (index != -1)
            {
                this._images[index] = this._control.InsertImage.Clone();
            }
        }

      

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {           
            if (this.Cal() == true)
            {
                this.DialogResult = true;
                this.Close();
            }
        }

        public bool Cal()
        {
            for (int i = 0; i < this._images.Count; i++)
            {
                switch (this._images[i].Method)
                {
                    case 0:
                        try
                        {
                            if (this._images[i].PointReal2.X == this._images[i].PointReal1.X || this._images[i].PointReal2.Y == this._images[i].PointReal1.Y)
                            {
                                MessageBox.Show(this._images[i].FileNameNoExen + " 采用两点定位法时请不要把两个点设置在水平或垂直方向上!", "提示", MessageBoxButton.OK);
                                this.lstFile.SelectedIndex = i;
                                return false;
                            }
                            else if (((this._images[i].Point2.X - this._images[i].Point1.X) * (this._images[i].PointReal2.X - this._images[i].PointReal1.X) <= 0) || ((this._images[i].Point2.Y - this._images[i].Point1.Y) * (this._images[i].PointReal2.Y - this._images[i].PointReal1.Y) <= 0))
                            {
                                MessageBox.Show(this._images[i].FileNameNoExen + " 设置的坐标反向，请重新设置!", "提示", MessageBoxButton.OK);
                                this.lstFile.SelectedIndex = i;

                                return false;
                            }
                            else
                            {
                                System.Drawing.Point LeftBottomPoint = new System.Drawing.Point();

                                LeftBottomPoint.X = this._images[i].PointReal2.X + (this._images[i].BackRect.X - this._images[i].Point2.X) * (this._images[i].PointReal1.X - this._images[i].PointReal2.X) / (this._images[i].Point1.X - this._images[i].Point2.X);
                                LeftBottomPoint.Y = this._images[i].PointReal2.Y + (this._images[i].BackRect.Y - this._images[i].Point2.Y) * (this._images[i].PointReal1.Y - this._images[i].PointReal2.Y) / (this._images[i].Point1.Y - this._images[i].Point2.Y);
                                this._images[i].LeftBottomPoint = LeftBottomPoint;

                                System.Drawing.Point RightTopPoint = new System.Drawing.Point();
                                RightTopPoint.X = this._images[i].PointReal1.X + (this._images[i].BackRect.X + this._images[i].BackRect.Width - this._images[i].Point1.X) * (this._images[i].PointReal2.X - this._images[i].PointReal1.X) / (this._images[i].Point2.X - this._images[i].Point1.X);
                                RightTopPoint.Y = this._images[i].PointReal1.Y + (this._images[i].BackRect.Y + this._images[i].BackRect.Height - this._images[i].Point1.Y) * (this._images[i].PointReal2.Y - this._images[i].PointReal1.Y) / (this._images[i].Point2.Y - this._images[i].Point1.Y);
                                this._images[i].RightTopPoint = RightTopPoint;
                            }


                        }
                        catch
                        {
                            MessageBox.Show("两点坐标设置不合理，导致两点坐标间距过大，引发运算错误！" + "请检查点坐标设置是否合理！", "提示", MessageBoxButton.OK);
                            this.lstFile.SelectedIndex = i;
                            return false;
                        }
                        break;
                    case 1:
                        try
                        {
                            if (this._images[i].DistanceReal <= 0)
                            {
                                MessageBox.Show(this._images[i].FileNameNoExen + " 设置的距离必须大于0，请重新设置!", "提示", MessageBoxButton.OK);
                                this.lstFile.SelectedIndex = i;
                                return false;
                            }
                            else if (this._images[i].SymbolDistancePoint1.SymbolVisible == false || this._images[i].SymbolDistancePoint2.SymbolVisible == false)
                            {
                                MessageBox.Show(this._images[i].FileNameNoExen + " 您没有设置两点距离对应的两点位置，请重新设置!", "提示", MessageBoxButton.OK);
                                this.lstFile.SelectedIndex = i;
                                return false;
                            }
                            else
                            {
                                double dis = GetDistance(this._images[i].DistancePoint1, this._images[i].DistancePoint2);

                                System.Drawing.Point LeftBottomPoint = new System.Drawing.Point();
                                LeftBottomPoint.X = (int)(this._images[i].CertainPointReal.X + (this._images[i].BackRect.X - this._images[i].CertainPoint.X) * this._images[i].DistanceReal / dis);
                                LeftBottomPoint.Y = (int)(this._images[i].CertainPointReal.Y + (this._images[i].BackRect.Y - this._images[i].CertainPoint.Y) * this._images[i].DistanceReal / dis);
                                this._images[i].LeftBottomPoint = LeftBottomPoint;

                                System.Drawing.Point RightTopPoint = new System.Drawing.Point();
                                RightTopPoint.X = (int)(this._images[i].CertainPointReal.X + (this._images[i].BackRect.X + this._images[i].BackRect.Width - this._images[i].CertainPoint.X) * this._images[i].DistanceReal / dis);
                                RightTopPoint.Y = (int)(this._images[i].CertainPointReal.Y + (this._images[i].BackRect.Y + this._images[i].BackRect.Height - this._images[i].CertainPoint.Y) * this._images[i].DistanceReal / dis);
                                this._images[i].RightTopPoint = RightTopPoint;


                                //   Dim LeftBottomPoint As Point
                                //LeftBottomPoint.X = .CertainPointReal.X + (.BackRect.X - .CertainPoint.X) * .DistanceReal / dis
                                //LeftBottomPoint.Y = .CertainPointReal.Y + (.BackRect.Y - .CertainPoint.Y) * .DistanceReal / dis
                                //.LeftBottomPoint = LeftBottomPoint
                                //Dim RightTopPoint As Point
                                //RightTopPoint.X = .CertainPointReal.X + (.BackRect.X + .BackRect.Width - .CertainPoint.X) * .DistanceReal / dis
                                //RightTopPoint.Y = .CertainPointReal.Y + (.BackRect.Y + .BackRect.Height - .CertainPoint.Y) * .DistanceReal / dis
                                //.RightTopPoint = RightTopPoint
                            }
                        }
                        catch
                        {
                            MessageBox.Show("两点距离或指定点坐标设置不合理，请重新设置！", "提示", MessageBoxButton.OK);
                            this.lstFile.SelectedIndex = i;
                            return false;
                        }

                        break;
                }
            }
            return true;
        }

        private double GetDistance(System.Drawing.Point p1, System.Drawing.Point p2)
        {
            return Math.Sqrt((p2.X - p1.X) * (p2.X - p1.X) + (p2.Y - p1.Y) * (p2.Y - p1.Y));
            
        }

  

        private void txtDistance_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                this._control.InsertImage.DistanceReal = Convert.ToDouble(this.txtDistance.Text);
                int index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();
                }
            }
            catch
            {
                MessageBox.Show("两点距离设置不合理，请重新输入！", "提示", MessageBoxButton.OK);
            }
        }

        private void txtSomeX_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Drawing.Point point = new System.Drawing.Point();
            try
            {
                double xxx=Convert .ToDouble (this.txtSomeX.Text);
                point.X = Convert.ToInt32(xxx);
                xxx = Convert.ToDouble(this.txtSomeY.Text);
                point.Y = Convert.ToInt32(xxx);
                this._control.InsertImage.CertainPointReal = point;
                int index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();
                }
            }
            catch
            {
                MessageBox.Show("指定点 X坐标设置不合理，请重新输入！", "提示", MessageBoxButton.OK);
            }
        }

        private void txtSomeY_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Drawing.Point point = new System.Drawing.Point();
            try
            {
                double xxx = Convert.ToDouble(this.txtSomeX.Text);
                point.X = Convert.ToInt32(xxx);
                xxx = Convert.ToDouble(this.txtSomeY.Text);
                point.Y = Convert.ToInt32(xxx);

                this._control.InsertImage.CertainPointReal = point;
                int index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();
                }
            }
            catch
            {
                MessageBox.Show("指定点 Y坐标设置不合理，请重新输入！", "提示", MessageBoxButton.OK);
            }
        }

        private void txtP1x_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Drawing.Point point = new System.Drawing.Point();
            try
            {
                double xxx = Convert.ToDouble(this.txtP1x.Text);
                point.X = Convert.ToInt32(xxx);
                xxx = Convert.ToDouble(this.txtP1y.Text);
                point.Y = Convert.ToInt32(xxx);
                this._control.InsertImage.PointReal1 = point;
                int index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();
                }
            }
            catch
            {
                MessageBox.Show("第一点：X1 坐标设置不合理，请重新输入！", "提示", MessageBoxButton.OK);
            }
        }

        private void txtP1y_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Drawing.Point point = new System.Drawing.Point();
            try
            {
                double xxx = Convert.ToDouble(this.txtP1x.Text);
                point.X = Convert.ToInt32(xxx);
                xxx = Convert.ToDouble(this.txtP1y.Text);
                point.Y = Convert.ToInt32(xxx);

                this._control.InsertImage.PointReal1 = point;
                int index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();
                }
            }
            catch
            {   
                MessageBox.Show("第一点：Y1 坐标设置不合理，请重新输入！", "提示", MessageBoxButton.OK);
            }
        }

        private void txtP2x_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Drawing.Point point = new System.Drawing.Point();
            try
            {
                double xxx = Convert.ToDouble(this.txtP2x.Text);
                point.X = Convert.ToInt32(xxx);
                xxx = Convert.ToDouble(this.txtP2y.Text);
                point.Y = Convert.ToInt32(xxx);
                this._control.InsertImage.PointReal2 = point;              
                int index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();              
                }              
            }
            catch
            {
                MessageBox.Show("第二点：X2 坐标设置不合理，请重新输入！", "提示", MessageBoxButton.OK);
            }
        }
       
        private void txtP2y_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Drawing.Point point = new System.Drawing.Point();
            try
            {
                double xxx = Convert.ToDouble(this.txtP2x.Text);
                point.X = Convert.ToInt32(xxx);
                xxx = Convert.ToDouble(this.txtP2y.Text);
                point.Y = Convert.ToInt32(xxx);
                this._control.InsertImage.PointReal2 = point;               
               int  index = this.lstFile.SelectedIndex;
                if (index != -1)
                {
                    this._images[index] = this._control.InsertImage.Clone();                 
                }              
            }
            catch
            {
                MessageBox.Show(" 第二点：Y2 坐标设置不合理，请重新输入！");
            }

        }

        private void lstFile_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
           int  index = this.lstFile.SelectedIndex;
           if (index != -1)
           {
               if (this._images[this.lstFile.SelectedIndex].Method == 0)
               {
                   this.rbtnCoordinate.IsChecked = true;
               }
               else
               {
                   this.rbtnDistance.IsChecked = true;
               }

               ShowImage();

               this.txtP1x.Text = this._control.InsertImage.PointReal1.X.ToString();
               this.txtP1y.Text = this._control.InsertImage.PointReal1.Y.ToString();

               this.txtP2x.Text = this._control.InsertImage.PointReal2.X.ToString();
               this.txtP2y.Text = this._control.InsertImage.PointReal2.Y.ToString();

               this.txtDistance.Text = this._control.InsertImage.DistanceReal.ToString();
               this.txtSomeX.Text = this._control.InsertImage.CertainPoint.X.ToString();

               this.txtSomeY.Text = this._control.InsertImage.CertainPoint.Y.ToString();
           }
        }

     
        /// <summary>
        /// 显示选择的图
        /// </summary>
        private void ShowImage()
        {
            if (this.rbtnCoordinate.IsChecked.Value)
            {
                this.groupCorrdinate.Visibility = System.Windows.Visibility.Visible;
                this.groupDistance.Visibility = System.Windows.Visibility.Hidden;
                if (this.lstFile.SelectedIndex >= 0)
                {
                    this._images[this.lstFile.SelectedIndex].Method = 0;
                }
            }
            else
            {
                this.groupCorrdinate.Visibility = System.Windows.Visibility.Hidden;
                this.groupDistance.Visibility = System.Windows.Visibility.Visible;
                if (this.lstFile.SelectedIndex >= 0)
                {
                    this._images[this.lstFile.SelectedIndex].Method = 1;
                }
            }
            if (this.lstFile.SelectedIndex >= 0)
            {
                this._control.InsertImage = this._images[this.lstFile.SelectedIndex].Clone();
                this._control.Refresh();                
            }
        }

       

        private void rbtnCoordinate_Click(object sender, RoutedEventArgs e)
        {
            ShowImage();
        }

        private void rbtnDistance_Click(object sender, RoutedEventArgs e)
        {
            ShowImage();
        }

        private void btnGoogle_Click(object sender, RoutedEventArgs e)
        {

            GEEditor.Form3 frmGoogle = new GEEditor.Form3(mLeftBelow.X, mLeftBelow.Y, mRightUpper.X, mRightUpper.Y);
            frmGoogle.GoogleParam = this.Google;
            if (Math.Floor(frmGoogle.GoogleParam.X) >= 999999999999999)
            {
                frmGoogle.GoogleParam.X = mLeftBelow.X;
                frmGoogle.GoogleParam.Y = mLeftBelow.Y;
            }
            if (frmGoogle.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strFile = frmGoogle.ImgFileName;
                if (strFile == "")
                {
                    return;
                }
                this._images.Add(new InsertImage());
                this._control.InsertImage = this._images[this._images.Count - 1];
                this._control.InsertImage.FileName = strFile;
                if (this._control.InsertImage.LoadBitmap(strFile) == false)
                {
                    return;
                }
                this._control.InsertImage.FileNameNoExen = InsertImage.GetFileName(ref  strFile);
                this.lstFile.Items.Add(this._control.InsertImage.FileNameNoExen);
                this.lstFile.SelectedIndex = this.lstFile.Items.Count - 1;
                this._control.Refresh();
                System.Drawing.PointF PointR1 = new PointF();
                PointR1.X = mLeftBelow.X;
                PointR1.Y = mLeftBelow.Y;
                this.txtP1x.Text = mLeftBelow.X.ToString();
                this.txtP1y.Text = mLeftBelow.Y.ToString();
                System.Drawing.PointF PointR2 = new PointF();
                PointR2.X = mRightUpper.X;
                PointR2.Y = mRightUpper.Y;
                this.txtP2x.Text = mRightUpper.X.ToString();
                this.txtP2y.Text = mRightUpper.Y.ToString();
                System.Drawing.Point p = new System.Drawing.Point();
                p.X = Convert.ToInt32(PointR1.X);
                p.Y = Convert.ToInt32(PointR1.Y);
                this._control.InsertImage.PointReal1 = p;
                p.X =Convert.ToInt32 ( PointR2.X);
                p.Y =Convert.ToInt32 ( PointR2.Y);

                this._control.InsertImage.PointReal2 = p ;

                System.Drawing.Point Point_1 = new System.Drawing.Point();
                System.Drawing.Point Point_2 = new System.Drawing.Point();



                Point_1.X = this._control.InsertImage.OriginX - this._control.InsertImage.ImageRect.Width / 2;
                Point_1.Y = this._control.InsertImage.OriginY + this._control.InsertImage.ImageRect.Height / 2;
                this._control.InsertImage.Point1 = this._control.InsertImage.ScreenToDraw(Point_1);

                Point_2.X = this._control.InsertImage.OriginX + this._control.InsertImage.ImageRect.Width / 2;
                Point_2.Y = this._control.InsertImage.OriginY - this._control.InsertImage.ImageRect.Height / 2;

                this._control.InsertImage.Point2 = this._control.InsertImage.ScreenToDraw(Point_2);

                //    '----------------------------------------------------
                //    '王如建增加的代码
                this.rbtnCoordinate.IsChecked = true;
                //'定位第一个点
                this._control.SetPoint = CImPortImage.PointType.TwoPoint_1;

                this._control.InsertImage.Symbol1.SymbolSign.mSymbolsPoint.X = this._control.InsertImage.Point1.X;
                this._control.InsertImage.Symbol1.SymbolSign.mSymbolsPoint.Y = this._control.InsertImage.Point1.Y;
                this._control.InsertImage.Symbol2.SymbolSign.mSymbolsPoint.X = this._control.InsertImage.Point2.X;
                this._control.InsertImage.Symbol2.SymbolSign.mSymbolsPoint.Y = this._control.InsertImage.Point2.Y;

                this._control.InsertImage.Symbol1.SymbolVisible = true;
                this._control.InsertImage.Symbol2.SymbolVisible = true;

                this._control.InsertImage.Symbol1.SymbolText.Visible = true;
                this._control.InsertImage.Symbol2.SymbolText.Visible = true;

                //    '王如建增加的代码结束
                //    '-------------------------------------------]
                this.Google = frmGoogle.GoogleParam;
            }
            InsertImage inser = this._control.InsertImage.Clone();
            this._control.OnInsertImageChanged(ref inser);


        }

        private void btnHand_Click(object sender, RoutedEventArgs e)
        {
            this._control.SetMouseType(0);// '箭头形
            this._control.MouseMoveType = 4;// '移动
            this._control.SetPoint = 0;
            // '移动
            this._control.SetMouseType(4);
        }

        private void btnZoomIn_Click(object sender, RoutedEventArgs e)
        {
            this._control.SetMouseType(0);// '箭头形
            this._control.MouseMoveType = 2;//'放大
            this._control.SetPoint = 0;
            this._control.SetMouseType(2);// '箭头形
        }

        private void btnZommOut_Click(object sender, RoutedEventArgs e)
        {
            this._control.SetMouseType(0);// '箭头形
            this._control.MouseMoveType = 3;// '缩小
            this._control.SetPoint = 0;
            this._control.SetMouseType(3);// '箭头形
        }
    }
}
